package com.atguigu.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.atguigu.dao.MemberDao;
import com.atguigu.pojo.Member;
import com.atguigu.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service(interfaceClass = MemberService.class)
@Transactional
public class MemberServiceImpl implements MemberService {
     @Autowired
     MemberDao memberDao;
    @Override
    public Member getMemberByTel(String telephone) {
        return memberDao.getMemberByPhone(telephone);
    }

    @Override
    public void add(Member member) {
        memberDao.add(member);
    }

    @Override
    public List<Integer> getMemberCountByMonths(List<String> months) {
        List<Integer> list = new ArrayList<>();
        for (String month : months) {
            Integer memberCountByMonth = memberDao.getMemberCountByMonth(month);
            list.add(memberCountByMonth);
        }
        return list;
    }
}
